import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class Main {

	private static final int NTHREADS = 100;
	private static BlockingQueue<Integer> integers = new ArrayBlockingQueue<Integer>(100);
	private static BlockingQueue<String> letters = new ArrayBlockingQueue<String>(100);
	
	public static void main(String...strings) {
		ExecutorService executor = Executors.newFixedThreadPool(NTHREADS);
		
		letters.add("1");
		
		long start = System.nanoTime();
		for (int i = 0; i < 100; i++) {
			if (i % 1000000 == 0) {
				System.out.println((System.nanoTime() - start)/1000000);
				start = System.nanoTime();
			}
			//System.out.println("Loop: " + (i + 1));
			Runnable a = new WorkerA(i, integers, letters);
			Runnable b = new WorkerB(i, integers, letters);
			executor.execute(a);
			executor.execute(b);
		}
		
		System.out.println("Loop ended");
		executor.shutdown();
		System.out.println("Executor shutdown");
		while (!executor.isTerminated()) { }
		System.out.println("Finished all threads");
	}
}
